package com.ibm.risk.irmp.workflow.client.flowable.api;

import com.ibm.risk.irmp.workflow.client.flowable.ApiClient;

import com.ibm.risk.irmp.workflow.client.flowable.model.CommentRequest;
import com.ibm.risk.irmp.workflow.client.flowable.model.CommentResponse;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;


@Component("com.ibm.risk.irmp.flowable.api.TaskCommentsApi")
public class TaskCommentsApi {
    private ApiClient apiClient;

    public TaskCommentsApi() {
        this(new ApiClient());
    }

    @Autowired
    public TaskCommentsApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Create a new comment on a task
     *
     * <p><b>200</b> - successful operation
     * <p><b>201</b> - Indicates the comment was created and the result is returned.
     * <p><b>400</b> - Indicates the comment is missing from the request.
     * <p><b>404</b> - Indicates the requested task was not found.
     * @param taskId The taskId parameter
     * @param body The body parameter
     * @return CommentResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public CommentResponse createTaskComments(String taskId, CommentRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'taskId' is set
        if (taskId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'taskId' when calling createTaskComments");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("taskId", taskId);
        String path = UriComponentsBuilder.fromPath("/runtime/tasks/{taskId}/comments").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<CommentResponse> returnType = new ParameterizedTypeReference<CommentResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Delete a comment on a task
     *
     * <p><b>204</b> - Indicates the task and comment were found and the comment is deleted. Response body is left empty intentionally.
     * <p><b>404</b> - Indicates the requested task was not found or the tasks does not have a comment with the given ID.
     * @param taskId The taskId parameter
     * @param commentId The commentId parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void deleteTaskComment(String taskId, String commentId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'taskId' is set
        if (taskId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'taskId' when calling deleteTaskComment");
        }

        // verify the required parameter 'commentId' is set
        if (commentId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'commentId' when calling deleteTaskComment");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("taskId", taskId);
        uriVariables.put("commentId", commentId);
        String path = UriComponentsBuilder.fromPath("/runtime/tasks/{taskId}/comments/{commentId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = { };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
        apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     *  Get a comment on a task
     *
     * <p><b>200</b> - Indicates the task and comment were found and the comment is returned.
     * <p><b>404</b> - Indicates the requested task was not found or the tasks does not have a comment with the given ID.
     * @param taskId The taskId parameter
     * @param commentId The commentId parameter
     * @return CommentResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public CommentResponse getTaskComment(String taskId, String commentId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'taskId' is set
        if (taskId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'taskId' when calling getTaskComment");
        }

        // verify the required parameter 'commentId' is set
        if (commentId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'commentId' when calling getTaskComment");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("taskId", taskId);
        uriVariables.put("commentId", commentId);
        String path = UriComponentsBuilder.fromPath("/runtime/tasks/{taskId}/comments/{commentId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<CommentResponse> returnType = new ParameterizedTypeReference<CommentResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * List comments on a task
     *
     * <p><b>200</b> - Indicates the task was found and the comments are returned.
     * <p><b>404</b> - Indicates the requested task was not found.
     * @param taskId The taskId parameter
     * @return List&lt;CommentResponse&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public List<CommentResponse> listTaskComments(String taskId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'taskId' is set
        if (taskId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'taskId' when calling listTaskComments");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("taskId", taskId);
        String path = UriComponentsBuilder.fromPath("/runtime/tasks/{taskId}/comments").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<List<CommentResponse>> returnType = new ParameterizedTypeReference<List<CommentResponse>>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
}
